#region Usings

using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Input;

#endregion

namespace KanbanBoard.Client.View.Converters {
    public class Command : ICommand {
        private readonly Action action;

        public Command(Action action) {
            this.action = action;
        }

        public bool CanExecute(object parameter) {
            return true;
        }

        public void Execute(object parameter) {
            action();
        }

        public event EventHandler CanExecuteChanged;
    }

    public class CommandConverter : IValueConverter {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
            var action = value as Action;
            return new Command(action);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
            var action = value as Action;
            return new Command(action);
        }
    }
}